package com.demo.user.controller;

import com.demo.common.base.pojo.JsonRes;
import com.demo.common.ratelimit.annotation.DistributeLock;
import com.demo.user.bo.CreateUserBO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 用户管理接口
 *
 * @author DayDayUp
 * create on 2023-05-18
 **/
@Slf4j
@RestController
@RequestMapping("user-admin")
public class TestController {

    /**
     * 分页查询用户
     * @return JsonRes
     */
    @GetMapping("/")
    public JsonRes<String> test() {
        return JsonRes.ok("user-admin");
    }


    @DistributeLock
    @GetMapping("/distributeLock")
    public JsonRes<String> distributeLock() throws InterruptedException {
        log.info("执行前");
        Thread.sleep(10000);
        log.info("执行后");
        return JsonRes.ok();
    }

    @PostMapping("upload")
    public JsonRes<String> upload(@RequestBody CreateUserBO createUserBO){

        System.out.println(createUserBO.getBase64());
        return JsonRes.ok();
    }
}
